//
//  FindVC.swift
//  d11
//
//  Created by mac on 2018/1/29.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit
import SnapKit

class FindVC: UIViewController{
     var navH: CGFloat?
     var activityDataChange: [[String:Any]]?
    var mtNavigation:UINavigationController?
    lazy var subviewTitles:[String] = {
        var array = [String]()
         if let activitycategoryData = GlobalInfo.activitycategoryData {
            for (value) in activitycategoryData{
                array.append(value["aname"] as! String)
            }
        }
//        let array = ["全部优惠","常规优惠","最新推荐","体育","真人娱乐","节假日","VIP成长"]
        return array
        
    }()
    
    lazy var VCManager:VCManagerView = {
        let statusHeight = UIApplication.shared.statusBarFrame.height
        let manager = VCManagerView(frame:CGRect.init(x: 0, y:0, width: kScreenW, height: 44))
        manager.delegate = self
        self.view.addSubview(manager)
        return manager
    }()

    lazy var pageMagager:PageManagerVC = {
        var array = [TabMineActivityTableViewController]()
          if let activitycategoryData = GlobalInfo.activitycategoryData {
        
            for index in 0...activitycategoryData.count-1 {
                let ac =  TabMineActivityTableViewController.instanceFromStoryboard()
                ac?.activityDataChange=self.activityDataChange
                ac?.mtNavigation=self.mtNavigation
                ac?.mtCode=String(index)
                array.append(ac!)
            }
            
        }
       

        let manager = PageManagerVC.init(superController: self, childControllerS:array)

        manager.delegate = self
        self.view.addSubview(manager.view)
        return manager
        
    }()
    override func viewWillAppear(_ animated: Bool) {
        self.tabBarController?.tabBar.isHidden=true
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        automaticallyAdjustsScrollViewInsets = false
        navigationController?.navigationBar.isTranslucent = false
        view.backgroundColor = UIColor.white
        
        VCManager.title_font = UIFont.systemFont(ofSize: 15)
        VCManager.sliderWidthType = .ButtonWidth
        VCManager.title_array = subviewTitles
        VCManager.selectedColor=UIColor(red: 1, green: 153/255, blue: 0, alpha: 1.0)
        setConstraint()
    }
    fileprivate func setConstraint(){
        
        pageMagager.view.snp.makeConstraints { (make) in
            make.top.equalTo(VCManager.snp.bottom)
            make.left.right.equalTo(view)
            make.bottom.equalTo(view.snp.bottom).offset(0)
        }
    }
}
extension FindVC:VCManagerDelegate,PageManagerVC_Delegate{
    
    
    func VCManagerDidSelected(_ VCManager: VCManagerView, index: NSInteger, title: String) {
        pageMagager.setCurrentVCWithIndex(index)
    }
    func PageManagerDidFinishSelectedVC(indexOfVC: NSInteger) {
        VCManager.reloadSelectedBT(at: indexOfVC)
    }
    
}


